import React,{Component} from 'react';
import ReactDOM from 'react-dom';

export default (WrappedComponent) => {
	class HighOrderComponent extends Component{
		constructor() {
			super();
			this.state={data:null};
		}

		componentWillMount() {
			fetch('/data.json',{
				method: 'GET'
			}).then(response => response.json()).then(data => {
				this.setState({data:data[this.props.data]});
			})
		}

		render() {
			return <WrappedComponent data={this.state.data}/>
		}
	}
	return HighOrderComponent;
}
